Skip Headers

Oracle® Database Backup and Recovery Basics 10g Release 2 (10.2) Part Number B14192-03 |
Home | Book List | Contents | Index | Master Index | Feedback

Previous | Next
| View PDF

# 8.3 Deleting Backups

You can use RMAN to delete backups created with RMAN. Deleting backups using RMAN both deletes the specified backups and updates the RMAN repository to reflect the deletion.

This section contains these topics:

- Deleting Specified Backups

- Deleting Expired RMAN Backups after CROSSCHECK

- Using DELETE FORCE With RMAN Backups

- Deleting Obsolete RMAN Backups Based on Retention Policies

  Note: Backups with `DELETED` status do not appear in the `LIST` command output. You can, however, query `V$` control file views to get information about deleted backups.

  See Also: Oracle Database Backup and Recovery Reference for `DELETE` syntax Oracle Database Backup and Recovery Reference for descriptions of the recovery catalog views

## 8.3.1 Deleting Specified Backups

In general, use the `DELETE` command to remove backups that you do not want to retain. `DELETE` removes the physical files from the backup media, deletes the record of the backup from the recovery catalog (if RMAN is connected to a recovery catalog), and updates the records of these backups in the control file to status `DELETED`.

The `DELETE` command supports deleting several types of backups, including:

`DELETE` `BACKUP` (which deletes backup sets, proxy copies, and image copies), `DELETE` `COPY` (which deletes only image copies), or `DELETE` `ARCHIVELOG` as in these examples:

The `DELETE` command supports a wide range of options to identify backups to delete. For complete information about these options, see Oracle Database Backup and Recovery Reference. The following examples show many of the common ways to specify backups and archived logs to delete using the`DELETE` command:

- Deleting backups using primary keys from `LIST` output:

      DELETE BACKUPPIECE 101;

- Deleting backups by filename on disk:

      DELETE CONTROLFILECOPY '/tmp/control01.ctl';

- Deleting archived redo logs from disk:

      DELETE NOPROMPT ARCHIVELOG UNTIL SEQUENCE = 300;

- Deleting backups based on tags:

      DELETE BACKUP TAG='before_upgrade';

- Delete backups based on the objects backed up and the media or disk location where the backup is stored:

      DELETE BACKUP OF TABLESPACE users DEVICE TYPE sbt; # delete only from tape
      DELETE COPY OF CONTROLFILE LIKE '/tmp/%';  #

- Delete all backups for this database recorded in the RMAN repository:

      DELETE BACKUP;

- Delete backups and archived redo logs from disk based on whether they are backed up on tape:

      DELETE ARCHIVELOG ALL
         BACKED UP 3 TIMES TO sbt;

If you run RMAN interactively, then RMAN asks for confirmation before deleting any files. You can suppress these confirmations by using the `NOPROMPT` keyword with any form of the `BACKUP` command:

    DELETE NOPROMPT ARCHIVELOG ALL;

## 8.3.2 Deleting Expired RMAN Backups after CROSSCHECK

When the `CROSSCHECK` command is used to determine whether backups recorded in the repository still exist on disk or tape, if RMAN cannot locate the backups, then it updates their records in the RMAN repository to `EXPIRED` status. You can then use the `DELETE` `EXPIRED` command to remove records of expired backups from the RMAN repository. If the expired files still exist, then the `DELETE` `EXPIRED` command terminates with an error.

To delete expired repository records:

1. If you have not performed a crosscheck recently, then issue a `CROSSCHECK` command. For example, issue:

       CROSSCHECK BACKUP; # checks backup sets and copies on configured channels

2. Delete the expired backups. For example, issue:

       DELETE EXPIRED BACKUP;

Note: The `DELETE EXPIRED` command issues warnings if any objects marked as `EXPIRED` actually exist. In rare cases, the repository can mark an object as `EXPIRED` even though the object exists. For example, a directory containing an object is corrupted at the time of the crosscheck, but is later repaired, or the media manager was not configured properly and reported some backups as not existing when they really existed.

## 8.3.3 Using DELETE FORCE With RMAN Backups

It is possible for the RMAN repository to indicate that an object has one status while the actual status of the object on the media is different. For example, the RMAN repository says that a backup set is `AVAILABLE` when it is in fact no longer present on disk or tape (or missing from the media manager's catalog of the contents of tapes or other backup media). If you attempt to delete the object, then you receive a warning such as the following:

    RMAN-06207: WARNING: 1 objects could not be deleted for DISK channel(s) due
    RMAN-06208:          to mismatched status.  Use CROSSCHECK command to fix status
    List of Mismatched objects
    ==========================
      Object Type   Filename/Handle
    --------------- ---------------------------------------------------
    Backup Piece    0id270ud_1_1

If you use the `DELETE` command with the optional `FORCE` keyword, RMAN deletes the specified backups, but ignores any I/O errors, including those that occur when a backup is missing from disk or tape. It then updates the RMAN repository to reflect the fact that the backup is deleted, regardless of whether RMAN was able to delete the file or whether the file was already missing. For example:

    DELETE FORCE NOPROMPT BACKUPSET TAG 'weekly_bkup';

See Also: Oracle Database Backup and Recovery Advanced User's Guide to learn about `DELETE` behavior when the backup media and repository are not synchronized Oracle Database Backup and Recovery Reference for `DELETE` command syntax

## 8.3.4 Deleting Obsolete RMAN Backups Based on Retention Policies

The RMAN `DELETE` command supports an `OBSOLETE` option, which deletes backups that are obsolete, that is, no longer needed to satisfy specified recoverability requirements. You can delete files obsolete according to the configured default retention policy, or another retention policy that you specify as an option to the `DELETE` `OBSOLETE` command. As with other forms of the `DELETE` command, the files deleted are removed from backup media, deleted from the recovery catalog, and marked as `DELETED` in the control file.

If you specify the `DELETE` `OBSOLETE` command with no arguments, then RMAN deletes all obsolete backups defined by the currently configured retention policy For example:

    DELETE OBSOLETE;

You can also use the `REDUNDANCY` or `RECOVERY` `WINDOW` clauses with `DELETE` to delete backups obsolete under a specific retention policy instead of the configured default:

    DELETE OBSOLETE REDUNDANCY = 3;

    DELETE OBSOLETE RECOVERY WINDOW OF 7 DAYS;

### 8.3.4.1 DELETE OBSOLETE Behavior When KEEP UNTIL Time Expires

`DELETE` `OBSOLETE` does not delete backups required to satisfy the specified retention policy, even if some backups have `KEEP UNTIL` times set which have passed to override the retention policy.

The `KEEP` `UNTIL` clause never causes RMAN to consider a backup obsolete, if the backup is still required to satisfy the retention policy. `KEEP` `UNTIL` can cause backups to be kept longer than the retention policy requires, but never causes a backup to become obsolete sooner than the retention policy requires.

Backups are never obsolete if they are still needed to meet the retention policy, regardless of any `KEEP` `UNTIL` time. With a recovery window-based retention policy, even if the specified `KEEP` `UNTIL` time has expired, the backup is retained if the backup is needed to satisfy the recovery window. With a redundancy-based retention policy, even if the specified `KEEP` `UNTIL` time has expired, the backup is retained as long as it is required to satisfy the redundancy requirement.